#include <func.h>


void handler(int sig)
{
    switch(sig)
    {
    case SIGINT:
        printf("Receive: SIFINT\n");
        _exit(0);
    case SIGQUIT:
        printf("Receive: SIFQUIT\n");
        _exit(0);
    case SIGTSTP:
        printf("Receive: SIFTSTP\n");
        _exit(0);
    }
        
}

int main(int argc, char* argv[])
{
    if(argc != 2)
        error(1, 0, "Usage: %s sig", argv[0]);

    if(strncmp(argv[1], "SIGINT", 6) == 0)
    {
        signal(SIGINT, handler);
    }
    else if(strncmp(argv[1], "SIGQUIT", 7) == 0)
    {
        signal(SIGQUIT, handler);
    }
    else if(strncmp(argv[1], "SIGTSTP", 7) == 0)
    {
        signal(SIGTSTP, handler);
    }

    while(1)
        sleep(5);
        
    return 0;
}

